<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Base Sprite</title>
</head>
<body>
  <canvas id="mycanvas" width="1200" height="600"></canvas>
  <script src="/js/sprite-core.js"></script>
  <script>
    const Sprite = spritejs.Sprite;
    const Layer = spritejs.Layer;
    const Group = spritejs.Group;
    const context = document.getElementById('mycanvas').getContext('2d');
    const layer = new Layer({context});

    const g = new Group();
    g.attr({
      // anchor: 0.5,
      pos: [150, 150],
      width: 200,
      // height: 100,
      bgcolor: 'grey',
      flexWrap: 'wrap',
      flexDirection: 'row',
      alignItems: 'stretch',
      justifyContent: 'space-between',
      display: 'flex',
    });
    layer.append(g);

    const s1 = new Sprite();
    s1.attr({
      size: [50, 50],
      // anchor: 0.5,
      // borderRadius: 25,
      bgcolor: 'red',
      // flex: 0,
    });

    const s2 = s1.cloneNode();
    s2.attr({
      bgcolor: 'blue',
      width: 100,
      border: [4, 'orange'],
      boxSizing: 'border-box',
      // flex: 1,
    });

    const s3 = s1.cloneNode();
    s3.attr({
      bgcolor: 'green',
      // scale: [2.0, 1],
    });

    const g2 = g.cloneNode();
    g2.attr({
      // height: 150,
      width: '',
      flexDirection: 'column',
      bgcolor: 'black',
      // flex: 1,
    });

    const s4 = s1.cloneNode();
    s4.attr({
      bgcolor: 'cyan',
    });
    const s5 = s1.cloneNode();
    s5.attr({
      bgcolor: 'orange',
      margin: [20, 20, -20, 20],
    });
    const s6 = s1.cloneNode();
    s6.attr({bgcolor: '#37c'});

    g2.append(s4, s5, s6);

    g.append(s1, s2, s3);
    // g.append(s4)
    g.append(g2);


    // g.animate([
    //   {width: 100},
    //   {width: 300},
    // ], {
    //   duration: 5000,
    //   iterations: Infinity,
    //   direction: 'alternate',
    // })
  </script>
</body>
</html>
